﻿using System;
using System.Collections.Generic;
namespace Common
{
	public class UserInputHandleManager
	{
		private static UserInputHandleManager userinputhandlemanager = new UserInputHandleManager();
		private Dictionary<string, Action> handle_maping = new Dictionary<string, Action>();

		public UserInputHandleManager() {}

		/// <summary>
		/// 获取单例
		/// </summary>
		/// <returns>The instance.</returns>
		public static UserInputHandleManager GetInstance() 
		{
			return userinputhandlemanager;
		}

		/// <summary>
		/// 注册处理函数
		/// </summary>
		/// <param name="input">Input.</param>
		/// <param name="func">Func.</param>
		public void RegisterHandle(string input, Action func)
		{
			handle_maping[input] = func;
		}

		/// <summary>
		/// 获取处理函数
		/// </summary>
		/// <returns>The hanlde.</returns>
		/// <param name="input">Input.</param>
		public Action GetHanlde(string input)
		{
			return handle_maping.ContainsKey(input) ? handle_maping[input] : null;
		}
	}
}
